Lay out a score, a health bar, hearts or a whole menu on a screen-sized canvas. Gbabel writes the script, and you call it with one line.
A HUD is the stuff drawn on top of your game: a score, a health bar, a row of hearts. A menu is a list you choose from: PLAY, OPTIONS, QUIT.
Instead of writing the drawing code yourself, you lay it out. You drag pieces around on a picture of the screen, and Gbabel writes a script for you. Then you call that script with one line.
The designer lives in the Code tab, in a section called HUD & Menus, under Macros.
hud_main for a HUD and pause_menu for a menu.Click a name in the list to open it again. Right-click it to rename, duplicate, show the script or delete it.
The designer is the big window with the screen in it. The pieces have a small window of their own, on the right, that always stays on top of the designer. Move the big window and the small one comes with it; move the small one and only it moves.
Drag a piece to move it. Drag the little squares around a Bar, a Panel or a Menu list to change its size. Dragging one side moves only that side, and the side across from it stays where it is. Drag a side past the other one and the box flips over and keeps growing.
Snap to grid makes a piece land on a multiple of the grid size. Turn it off to put a piece on the exact pixel. The arrow keys nudge the picked piece one pixel, and Shift with an arrow moves it one grid step.
Undo works the way it does everywhere else in Gbabel. One change is one step.
The numbers and words you see for a variable are sample values. They are only for the picture, so you can see what 120 coins looks like. You can type your own under Sample values for the picture. The game uses the real numbers.
Under the picture, Things to fix says in plain words what is not finished yet, like a piece with no variable picked.
| Piece | What it draws |
|---|---|
| Text | Words. Pick a font, where the words line up, and the text effects they wear. |
| Value | A variable shown as a number or as words, like a score. It can put zeros in front (000120), and words before and after (x7, 3/5). |
| Bar | A bar that fills up as a variable goes up. You pick the variable, what "full" is, the colors and which way it grows, and a sprite effect for its tint. |
| Sprite | One of your sprites, and which frame (picture) of it, and a sprite effect. |
| Row of icons | Hearts, stars or coins. Each icon is full, half or empty, depending on one variable, and the row can wear a sprite effect. |
| Panel | A filled box, an outline, a sprite behind everything else, or any mix. |
| Menu list | The choices of a menu, with a cursor. Only a menu has one. |
A Bar, a Panel and the menu's cursor use the eight colors Gbabel can fill a box with: white, black, red, green, blue, yellow, cyan and magenta.
From a palette. Under each color there is From a palette. Pick one of your palettes (the ones you made in the Paint tab), then click one of its 16 colors. A box can only be drawn in the eight colors above, so Gbabel uses the nearest of them to the one you clicked, and says which. If you pick a color from the list afterwards, it is a plain color again.
A sprite can have many frames, one picture after another. Wherever you pick a sprite (a Sprite piece, a Panel's sprite, a menu's sprite cursor) a small box under it shows the frame and has arrows to pick another. A Row of icons has a sprite and a frame for each of Full, Half and Empty, so one sprite sheet can hold all three hearts.
A Value, a Bar or a Row of icons reads a variable. You choose where it lives.
global.score.hp.Pick the name from the list, or type it. The list shows what your game already has. A number that is shown has to be a whole number. If your variable has a decimal point, round it first with int_floor.
Words can wear the text effects you made in the Overlay Effects tab. Open Effects on a Text, a Value, a menu's title, an item or the arrow, click + Add an effect, and pick the effect and when it plays:
A line can wear up to three effects; the first one whose time has come plays. The picture in the designer shows the words plain, because an effect is made by the console. Play the game to see it.
Under Full icon, Half icon and Empty icon of a Row of icons, tick Animate to make that icon change frames by itself. All frames (the usual) uses every frame of the sprite. Untick it to use only some, like frames 3 to 6 for the empty icon.
A Bar, a Sprite and a Row of icons can wear a sprite effect from the Overlay Effects tab: a tint that pulses, a wobble, a turn, a fade. Open Effect on the piece and pick one under Sprite effect; (none) takes it off. The effect plays all the time, by its own motion, from the moment the game draws the piece, and the picture in the designer plays it too (an effect that plays once plays once, and then the piece is drawn plainly, as it is in the game).
A Sprite and a Row of icons wear everything the effect has: tint, wobble, distort, scale, rotate, blocks and see-through. A Bar wears only the effect's tint: its colors mix toward the effect's color as the effect pulses (a bar with an effect that has no tint shows a note in the Problems list). Two pieces with different effects each keep their own clock, so a bar can pulse while the hearts wobble.
Gbabel writes draw_effect_start before the piece's pictures and draw_effect_stop after them, the way a text effect sits around words. Every different effect a HUD uses takes one of the places the game keeps for sprite effects playing at once, and a wobble or a distort also takes row-by-row effects while its pictures are on the screen: the room's gauges count them. A console that cannot play sprite effects grays out the choice.
A Panel's sprite is not stuck to the top-left corner. Click one of the nine spots under Place it to put the whole sprite in a corner, against an edge or in the middle of the panel, or type Sprite left and Sprite top to put it anywhere inside.
A Row of icons has a How many box and an Each is worth box. Three hearts that can each be half full are How many: 3 and Each is worth: 2, so the variable runs from 0 to 6. Pick a Full, a Half and an Empty sprite. Leave one out and nothing is drawn for it.
A HUD is one script. Call it from a Draw GUI event, because that draws on the screen itself and not in the room:
// obj_hud - Draw GUI event
hud_main();That draws everything. Change the design in the designer and the same line draws the new look. Nothing to rewrite.
A menu is one script too, and one call does all of it. Call it every frame in a Draw GUI event:
// obj_menu - Draw GUI event
var choice = pause_menu();
if (choice == 0) { room_next(); } // the first item, PLAY
else if (choice == 1) { room_restart(); } // the second itemEvery frame, pause_menu() draws the menu, moves the cursor when the player presses Up or Down, and lets A choose. It gives you back a number:
| It gives back | It means |
|---|---|
| -1 | Nothing yet. Keep calling it. |
| 0, 1, 2 ... | The player pressed A on that item. The first item in the list is 0. |
| -2 | The player pressed B, and you let B back out. |
The menu remembers its cursor from one frame to the next. After it gives back a choice, the cursor jumps back to the item you picked as Starts on, so the next time the menu opens it begins fresh.
The Menu list has a few settings:
Every line of words in a menu (the title, each item, the arrow) can have its own font, its own line-up (left, center or right) and a shift across and down. Open More for item 0 under an item to find them. A line you leave alone uses the menu's own font and line-up.
Open Sounds in the menu's settings to pick a Move sound (played each time the cursor goes to another item, and not when it stays where it is, as at the top of a menu that does not wrap) and a Select sound (played when A chooses an item; backing out with B plays nothing). Leave a box at (none) and the menu makes no sound there. You can still play sounds yourself from the code that calls the menu.
Under Look, Grayed font draws the items that fail their Only when test in another font, and Grayed effect gives them a text effect from the Overlay Effects tab instead (a dim color works well). A grayed-out item wears only that effect, not its own. The picture in the designer shows a grayed font as it is, and an item with a grayed effect pale (the effect itself plays only in the game). A menu that picks neither draws a grayed-out item like any other, so pick one of them if the player should see which items are off.
A cursor that is a sprite can look different when a button is pressed. Under When a button is pressed, pick Changes while a button is held or Changes for a moment after a click, pick the button, and pick the frame (or another sprite) it turns into. Tick Show it pressed to see it in the picture. Under Animation, tick Animate to make the cursor change frames by itself: every frame of the sprite (All frames, the usual), or just the frames from one number to another, at the Speed you choose (how many game frames each picture stays; 60 is one second).
The script Gbabel writes is read-only in the code editor. Every time you change the design the script is written again, so a change you typed into it would be lost. At the top of its window you see Made by the HUD designer and two buttons:
hud_main_mine that you can edit however you like. The copy is no longer connected to the designer. The original stays the designer's, and your code still calls the original until you change it to call the copy.